package o;

import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import androidx.annotation.ColorInt;
import androidx.annotation.IntRange;
import androidx.annotation.Nullable;
import com.google.android.material.internal.Experimental;

@Experimental("The shapes API is currently experimental and subject to change")
public class ass extends Drawable implements gf {
    private final Path ʻ;
    private float ʻॱ;
    private final Region ʼ;
    private Mode ʼॱ;
    private final Region ʽ;
    private Style ʽॱ;
    @Nullable
    private PorterDuffColorFilter ʾ;
    private float ʿ;
    private float ˈ;
    private final Matrix[] ˊ;
    private boolean ˊॱ;
    private ColorStateList ˊᐝ;
    private final Paint ˋ;
    private boolean ˋॱ;
    private final Matrix[] ˎ;
    private final asp[] ˏ;
    private final float[] ˏॱ;
    @Nullable
    private asq ͺ;
    private final Matrix ॱ;
    private final float[] ॱˊ;
    private int ॱˋ;
    private int ॱˎ;
    private final asp ॱॱ;
    private int ॱᐝ;
    private final PointF ᐝ;
    private int ᐝॱ;

    public ass() {
        this(null);
    }

    public ass(@Nullable asq o_asq) {
        int i = 0;
        this.ˋ = new Paint();
        this.ˊ = new Matrix[4];
        this.ˎ = new Matrix[4];
        this.ˏ = new asp[4];
        this.ॱ = new Matrix();
        this.ʻ = new Path();
        this.ᐝ = new PointF();
        this.ॱॱ = new asp();
        this.ʽ = new Region();
        this.ʼ = new Region();
        this.ˏॱ = new float[2];
        this.ॱˊ = new float[2];
        this.ͺ = null;
        this.ˊॱ = false;
        this.ˋॱ = false;
        this.ʻॱ = 1.0f;
        this.ॱᐝ = -16777216;
        this.ᐝॱ = 5;
        this.ॱˎ = 10;
        this.ॱˋ = 255;
        this.ʿ = 1.0f;
        this.ˈ = 0.0f;
        this.ʽॱ = Style.FILL_AND_STROKE;
        this.ʼॱ = Mode.SRC_IN;
        this.ˊᐝ = null;
        this.ͺ = o_asq;
        while (i < 4) {
            this.ˊ[i] = new Matrix();
            this.ˎ[i] = new Matrix();
            this.ˏ[i] = new asp();
            i++;
        }
    }

    private static int ˊ(int i, int i2) {
        return (((i2 >>> 7) + i2) * i) >>> 8;
    }

    public void setTintList(ColorStateList colorStateList) {
        this.ˊᐝ = colorStateList;
        ˏ();
        invalidateSelf();
    }

    public void setTintMode(Mode mode) {
        this.ʼॱ = mode;
        ˏ();
        invalidateSelf();
    }

    public void setTint(@ColorInt int i) {
        setTintList(ColorStateList.valueOf(i));
    }

    public int getOpacity() {
        return -3;
    }

    public void setAlpha(@IntRange(from = 0, to = 255) int i) {
        this.ॱˋ = i;
        invalidateSelf();
    }

    public void setColorFilter(@Nullable ColorFilter colorFilter) {
        this.ˋ.setColorFilter(colorFilter);
        invalidateSelf();
    }

    public Region getTransparentRegion() {
        Rect bounds = getBounds();
        this.ʽ.set(bounds);
        ˋ(bounds.width(), bounds.height(), this.ʻ);
        this.ʼ.setPath(this.ʻ, this.ʽ);
        this.ʽ.op(this.ʼ, Op.DIFFERENCE);
        return this.ʽ;
    }

    public void ॱ(boolean z) {
        this.ˊॱ = z;
        invalidateSelf();
    }

    public float ॱ() {
        return this.ʻॱ;
    }

    public void ˋ(float f) {
        this.ʻॱ = f;
        invalidateSelf();
    }

    public void ॱ(Style style) {
        this.ʽॱ = style;
        invalidateSelf();
    }

    public void draw(Canvas canvas) {
        this.ˋ.setColorFilter(this.ʾ);
        int alpha = this.ˋ.getAlpha();
        this.ˋ.setAlpha(ˊ(alpha, this.ॱˋ));
        this.ˋ.setStrokeWidth(this.ˈ);
        this.ˋ.setStyle(this.ʽॱ);
        if (this.ᐝॱ > 0 && this.ˊॱ) {
            this.ˋ.setShadowLayer((float) this.ॱˎ, 0.0f, (float) this.ᐝॱ, this.ॱᐝ);
        }
        if (this.ͺ != null) {
            ˋ(canvas.getWidth(), canvas.getHeight(), this.ʻ);
            canvas.drawPath(this.ʻ, this.ˋ);
        } else {
            canvas.drawRect(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight(), this.ˋ);
        }
        this.ˋ.setAlpha(alpha);
    }

    public void ॱ(int i, int i2, Path path) {
        int i3 = 0;
        path.rewind();
        if (this.ͺ != null) {
            for (int i4 = 0; i4 < 4; i4++) {
                ˎ(i4, i, i2);
                ˏ(i4, i, i2);
            }
            while (i3 < 4) {
                ˋ(i3, path);
                ˎ(i3, path);
                i3++;
            }
            path.close();
        }
    }

    private void ˎ(int i, int i2, int i3) {
        ˊ(i, i2, i3, this.ᐝ);
        ˏ(i).ˊ(ˋ(i, i2, i3), this.ʻॱ, this.ˏ[i]);
        float ॱ = ॱ(((i - 1) + 4) % 4, i2, i3) + 1.5707964f;
        this.ˊ[i].reset();
        this.ˊ[i].setTranslate(this.ᐝ.x, this.ᐝ.y);
        this.ˊ[i].preRotate((float) Math.toDegrees((double) ॱ));
    }

    private void ˏ(int i, int i2, int i3) {
        this.ˏॱ[0] = this.ˏ[i].ˎ;
        this.ˏॱ[1] = this.ˏ[i].ˊ;
        this.ˊ[i].mapPoints(this.ˏॱ);
        float ॱ = ॱ(i, i2, i3);
        this.ˎ[i].reset();
        this.ˎ[i].setTranslate(this.ˏॱ[0], this.ˏॱ[1]);
        this.ˎ[i].preRotate((float) Math.toDegrees((double) ॱ));
    }

    private void ˋ(int i, Path path) {
        this.ˏॱ[0] = this.ˏ[i].ॱ;
        this.ˏॱ[1] = this.ˏ[i].ˏ;
        this.ˊ[i].mapPoints(this.ˏॱ);
        if (i == 0) {
            path.moveTo(this.ˏॱ[0], this.ˏॱ[1]);
        } else {
            path.lineTo(this.ˏॱ[0], this.ˏॱ[1]);
        }
        this.ˏ[i].ˏ(this.ˊ[i], path);
    }

    private void ˎ(int i, Path path) {
        int i2 = (i + 1) % 4;
        this.ˏॱ[0] = this.ˏ[i].ˎ;
        this.ˏॱ[1] = this.ˏ[i].ˊ;
        this.ˊ[i].mapPoints(this.ˏॱ);
        this.ॱˊ[0] = this.ˏ[i2].ॱ;
        this.ॱˊ[1] = this.ˏ[i2].ˏ;
        this.ˊ[i2].mapPoints(this.ॱˊ);
        float hypot = (float) Math.hypot((double) (this.ˏॱ[0] - this.ॱˊ[0]), (double) (this.ˏॱ[1] - this.ॱˊ[1]));
        this.ॱॱ.ˊ(0.0f, 0.0f);
        ˎ(i).ˎ(hypot, this.ʻॱ, this.ॱॱ);
        this.ॱॱ.ˏ(this.ˎ[i], path);
    }

    private asm ˏ(int i) {
        switch (i) {
            case 1:
                return this.ͺ.ˋ();
            case 2:
                return this.ͺ.ˏ();
            case 3:
                return this.ͺ.ॱ();
            default:
                return this.ͺ.ˎ();
        }
    }

    private aso ˎ(int i) {
        switch (i) {
            case 1:
                return this.ͺ.ʼ();
            case 2:
                return this.ͺ.ʽ();
            case 3:
                return this.ͺ.ॱॱ();
            default:
                return this.ͺ.ˊ();
        }
    }

    private void ˊ(int i, int i2, int i3, PointF pointF) {
        switch (i) {
            case 1:
                pointF.set((float) i2, 0.0f);
                return;
            case 2:
                pointF.set((float) i2, (float) i3);
                return;
            case 3:
                pointF.set(0.0f, (float) i3);
                return;
            default:
                pointF.set(0.0f, 0.0f);
                return;
        }
    }

    private float ˋ(int i, int i2, int i3) {
        ˊ(((i - 1) + 4) % 4, i2, i3, this.ᐝ);
        float f = this.ᐝ.x;
        float f2 = this.ᐝ.y;
        ˊ((i + 1) % 4, i2, i3, this.ᐝ);
        float f3 = this.ᐝ.x;
        float f4 = this.ᐝ.y;
        ˊ(i, i2, i3, this.ᐝ);
        float f5 = this.ᐝ.x;
        float f6 = this.ᐝ.y;
        f4 -= f6;
        f = ((float) Math.atan2((double) (f2 - f6), (double) (f - f5))) - ((float) Math.atan2((double) f4, (double) (f3 - f5)));
        if (f < 0.0f) {
            return (float) (((double) f) + 6.283185307179586d);
        }
        return f;
    }

    private float ॱ(int i, int i2, int i3) {
        int i4 = (i + 1) % 4;
        ˊ(i, i2, i3, this.ᐝ);
        float f = this.ᐝ.x;
        float f2 = this.ᐝ.y;
        ˊ(i4, i2, i3, this.ᐝ);
        return (float) Math.atan2((double) (this.ᐝ.y - f2), (double) (this.ᐝ.x - f));
    }

    private void ˋ(int i, int i2, Path path) {
        ॱ(i, i2, path);
        if (this.ʿ != 1.0f) {
            this.ॱ.reset();
            this.ॱ.setScale(this.ʿ, this.ʿ, (float) (i / 2), (float) (i2 / 2));
            path.transform(this.ॱ);
        }
    }

    private void ˏ() {
        if (this.ˊᐝ == null || this.ʼॱ == null) {
            this.ʾ = null;
            return;
        }
        int colorForState = this.ˊᐝ.getColorForState(getState(), 0);
        this.ʾ = new PorterDuffColorFilter(colorForState, this.ʼॱ);
        if (this.ˋॱ) {
            this.ॱᐝ = colorForState;
        }
    }
}
